﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WFcontrol
{
    public partial class Frm_Listview : Form
    {
        public Frm_Listview()
        {
            InitializeComponent();
        }

        private void Frm_Listview_Load(object sender, EventArgs e)
        {
            DataTable tb = new DataTable();
            tb.Columns.Add("hoten");
            tb.Columns.Add("ngaysinh");
            tb.Columns.Add("gioitinh");

            DataRow dr;
            dr = tb.NewRow();
            dr[0] = "Pham Thi Van Tra";
            dr[1] = "19/4";
            dr[2] = "nu";
            tb.Rows.Add(dr);

            dr = tb.NewRow();
            dr[0] = "Nguyen huu hoai nam";
            dr[1] = "5/9";
            dr[2] = "nam";
            tb.Rows.Add(dr);

            dr = tb.NewRow();
            dr[0] = "Pham Thi kim chi";
            dr[1] = "2/10";
            dr[2] = "nu";
            tb.Rows.Add(dr);

            int i = 0;
            foreach (DataRow row in tb.Rows)
            {
                ListViewItem it = new ListViewItem();
                it.Text = row[0].ToString();
                it.ImageIndex = i;
                ListViewItem.ListViewSubItem subit_ns = new ListViewItem.ListViewSubItem();
                subit_ns.Text = row[1].ToString();
                it.SubItems.Add(subit_ns);
                ListViewItem.ListViewSubItem subit_gt = new ListViewItem.ListViewSubItem();
                subit_gt.Text = row[2].ToString();
                it.SubItems.Add(subit_gt);

                listView2.Items.Add(it);
                i++;
            }
        }


    }
}
